<template>
	<div>
		<div class="imgWarp" style="margin-top: 0;">
			<img :src="imgSrc" alt="">
		</div>
		<div class="demos-content-padded" style="padding: 0.3rem 1.1rem;" v-if='status!=1'>
			<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_default Register" style="float: left;" @click="unfinishClick">未运完</a>
			<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary Login" @click="finishClick" style="float: right;margin-top: 0;background: #28c81e;">已运完</a>
		</div>
	</div>
</template>

<script>
	import { getTranOver } from '../../config/api'
	import { imgBaseUrl } from '../../config/axios'
	import { Toast } from 'we-vue'
	export default{
		data(){
			return {
				status: this.$route.query.status,
				orderNo:this.$route.query.orderNo,
				imgSrc:''
			}
		},
		mounted(){
			getTranOver(this.orderNo).then(res=>{
				if(res.code==100){
					this.imgSrc = imgBaseUrl+res.content
				}else{
					Toast.fail('暂无数据');
				}
			}).catch(err=>console.log(err))
		},
		methods: {
			unfinishClick() {
				cancelTransOver(this.orderNo).then(res=>{
					if(res.code==100){
						Toast.success({
							duration:1200,
							message:res.content
						})
						setTimeout(()=>{
								this.$router.push('/mine')
							}, 1200)
					}else{
						Toast.fail(res.content)
					}
				}).catch(err=>console.log(err))
			},
			finishClick(){
				confirmTransOver(this.orderNo).then(res=>{
					if(res.code==100){
						Toast.success({
							duration:1200,
							message:res.content
						})
						setTimeout(()=>{
								this.$router.push('/mine')
							}, 1200)
					}else{
						Toast.fail(res.content)
					}
				}).catch(err=>console.log(err))
			}
		},
	}
</script>

<style>
</style>
